<template>
  <el-table :data="permissions" style="width: 100%" stripe border>
    <!-- index 序列 -->
    <el-table-column label="#" type="index" align="center" />

    <!-- 角色名称 -->
    <el-table-column prop="permissionName" label="权限名" align="center" />

    <!-- 角色描述 -->
    <el-table-column prop="url" label="权限uri" align="center" />
  </el-table>
</template>

<script>
// 接口
import { getPermissionByRid } from '@/network/roleControlRequest.js'

export default {
  data() {
    return {
      permissions: []
    }
  },
  props: {
    rid: String
  },
  // created() { console.log('创建'); },
  methods: {
    /**
     * 获取指定角色的所有权限
     */
    async getRolePermissions() {
      this.permissions = []; // 重置
      const { meta, data } = await getPermissionByRid(this.rid)

      // 失败
      // console.log(meta);
      if (meta.status != 200) {   
        return this.$message.error(meta.msg); 
      }

      // 成功
      this.permissions = data.permissions
      // console.log(this.permissions);
    }
  }
}
</script>

